package com.jybd.live.dao.impl;

import com.jybd.live.dao.RecordDao;
import com.jybd.live.mapper.RecordMapper;
import com.jybd.live.model.Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RecordDaoImpl implements RecordDao {

    private RecordMapper recordMapper;

    @Autowired
    public RecordDaoImpl(RecordMapper recordMapper) {
        this.recordMapper = recordMapper;
    }

    @Override
    public boolean insert(Record record) {
        int result = recordMapper.insertSelective(record);
        return result == 1;
    }

    @Override
    public List<Record> getByAppAndStream(String app, String stream) {
        return recordMapper.selectByAppAndStream(app, stream);
    }

    @Override
    public Record getById(Integer id) {
        return recordMapper.selectByPrimaryKey(id);
    }
}
